<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>管理系统</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/layer/layer.js"></script>
    <script>
        <c:if test="${info != null || info != ''}">
        layer.ready(function(){
            layer.open({
                type: 1,
                area : ["200px", "75px"],
                closeBtn: 0, //不显示关闭按钮
                title : false,
                anim: 4,
                shadeClose: true, //开启遮罩关闭
                time: 2000,
                content:  '<div style="margin: auto; width: 100%; height: 100%" class="alert alert-success" role="alert"><h4 style="text-align: center">${info}</h4></div>',
            });
        });
        </c:if>
    </script>
</head>

<body data-theme="translucent">
<!--End 左侧导航-->
<%@ include file="../jsp/left.jsp"%>

<!--头部信息-->
<%@ include file="../jsp/head.jsp"%>

<!--End 头部信息-->

<!--页面主要内容-->
<main class="lyear-layout-content">

    <div class="container-fluid">

        <div class="row">
            <div class="col-lg-12 col-md-12">
                <div class="card">
                    <div class="card-toolbar clearfix">
                        <form class="form-inline" action="${pageContext.request.contextPath}/tea/condition" method="get" id="headForm">
                            <div class="form-group">
                                <label class="sr-only control-label" for="title">职称:</label>
                                <div class="col-md-4 col-md-offset-7">
                                <select class="selectpicker form-control" name="title" id="title" data-with="auto" data-maxwidth="270px" data-width="270px">
                                <option selected value="0">--- 请选择需要筛选的职称信息 ---</option>
                                    <c:forEach var="title" items="${titleList}" varStatus="id">
                                        <option value="${id.count}">${title.title}</option>
                                    </c:forEach>
                                </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="sr-only control-label" for="college">学院:</label>
                                <div class="col-md-4 col-md-offset-11">
                                <select class="selectpicker form-control" name="college" id="college" data-maxwidth="270px" data-width="270px">
                                    <option selected value="0">--- 请选择需要筛选的学院信息 ---</option>
                                    <c:forEach var="college" items="${collegeList}" varStatus="id">
                                        <option value="${id.count}">${college.college}</option>
                                    </c:forEach>
                                </select>
                                </div>
                            </div>
                            <div class="form-group col-md-offset-4">
                                <button id="filter" class="btn btn-default" type="submit">查询</button>
                            </div>
                        </form>
                    <div class="card-body">
                        <div class="table-responsive">

                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th class="text-center">工号</th>
                                    <th class="text-center">姓名</th>
                                    <th class="text-center">所属学院</th>
                                    <th class="text-center">研究方向</th>
                                    <th class="text-center">职称</th>
                                    <th class="text-center">状态</th>
                                    <th class="text-center">操作</th>
                                </tr>
                                </thead>
                                <tbody>

                                <c:forEach var="teacher" items="${teacherList}" varStatus="t">
                                <tr class="text-center">
                                    <td>${teacher.tid}</td>
                                    <td>${teacher.name}</td>
                                    <td>${teacher.college}</td>
                                    <td>${teacher.profession}</td>
                                    <td>${teacher.title}</td>
                                    <c:if test="${teacher.status.equals('在职')}">
                                        <td><font class="text-success">${teacher.status}</font></td>
                                    </c:if>
                                    <c:if test="${!teacher.status.equals('在职')}">
                                        <td><font class="text-danger">${teacher.status}</font></td>
                                    </c:if>
                                    <td>
                                        <div class="btn-group">
                                            <button type="button" onclick="var s = parseInt(${"" + teacher.tid});view(s);" id="view" class="btn btn-xs btn-default" title="查看" data-toggle="tooltip"><i class="mdi mdi-eye"></i></button>
                                            <button type="button" onclick="var s = parseInt(${"" + teacher.tid});modify(s);" id="modify" class="btn btn-xs btn-default" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></button>
                                        </div>
                                    </td>
                                </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                        <ul class="pagination">
<%--                            <c:if test="${page.getPageNum() != 1}">--%>
                                <li><a href="${pageContext.request.contextPath}/tea/getList?pg=${currentPage - 1}">«</a></li>
<%--                            </c:if>--%>
<%--                            <c:if test="${page.getPageNum() == 1}">--%>
<%--                                <li class="disabled"><a href="${pageContext.request.contextPath}/tea/getList?pg=${(page.getTotal() - (page.getTotal() % page.getPageSize()))  / page.getPageSize()}">«</a></li>--%>
<%--                            </c:if>--%>
                            <c:if test="${pages != null}">
                            <c:forEach begin="0" end="${pages - 1}" varStatus="t">
                                <li><a href="${pageContext.request.contextPath}/tea/getList?pg=${t.count}">${t.count}</a></li>
                            </c:forEach>
                            </c:if>
<%--                            <c:if test="${page.getPageNum() != ((page.getTotal() - (page.getTotal() % page.getPageSize())) + 1)  /page.getPageSize()}">--%>
                                <li><a href="${pageContext.request.contextPath}/tea/getList?pg=${currentPage + 1}">»</a></li>
<%--                            </c:if>--%>
<%--                            <c:if test="${page.getPageNum() == ((page.getTotal() - (page.getTotal() % page.getPageSize())) + 1)  /page.getPageSize()}">--%>
<%--                                <li><a class="disabled" href="${pageContext.request.contextPath}/tea/getList?pg=1">»</a></li>--%>
<%--                            </c:if>--%>
                        </ul>

                    </div>
                </div>
            </div>

        </div>

    </div>

    </div>

</main>



<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/layer/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-select/bootstrap-select.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/main.min.js"></script>


<script>
    function view(tid) {
        // alert(tid);
        layer.open({
            type: 2,
            title: false,
            closeBtn: 0, //不显示关闭按钮
            shade: [0],
            area: ['500px', '700px'],
            shadeClose: true,
            anim: 2,
            content: ['/tea/view?tid=0' + tid, 'no'], //iframe的url，no代表不显示滚动条
        });
    }
</script>


<script>
    function modify(tid) {
        // alert(tid);
        layer.open({
            type: 2,
            title: false,
            closeBtn: 0, //不显示关闭按钮
            shade: [0],
            shadeClose: true,
            area: ['500px', '700px'],
            anim: 2,
            content: ['/tea/toModify?tid=0' + tid, 'no'], //iframe的url，no代表不显示滚动条
            end: function () {
                location.reload()
            }
        });
    }
</script>






<%--<script>--%>
<%--    $("#filter").on("click", function () {--%>
<%--        $.ajax({--%>
<%--            url: "${pageContext.request.contextPath}/tea/condition",--%>
<%--            data: $("#headForm").serialize(),--%>
<%--            dataType: "json",--%>
<%--            complete: function () {--%>
<%--                var info = String(${info});--%>
<%--                if (info != null && info !== "") {--%>
<%--                    layer.open({--%>
<%--                        type: 1,--%>
<%--                        area : ["150px", "75px"],--%>
<%--                        closeBtn: 0, //不显示关闭按钮--%>
<%--                        title : false,--%>
<%--                        anim: 6,--%>
<%--                        shadeClose: true, //开启遮罩关闭--%>
<%--                        time: 2000,--%>
<%--                        content:  '<div style="margin: auto; width: 100%; height: 100%" class="alert alert-success" role="alert"><h4 style="text-align: center">${info}</h4></div>',--%>
<%--                    });--%>
<%--                    setTimeout(function () {--%>
<%--                        $.ajax({--%>
<%--                            url: "${pageContext.request.contextPath}/tea/getList",--%>
<%--                            type: "POST",--%>
<%--                        });--%>
<%--                    }, 2000);--%>
<%--                }--%>
<%--            }--%>
<%--        })--%>
<%--    });--%>
<%--</script>--%>
</body>
</html>